package goover.unit04;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class FileReaderDemo01 {
    public static void main(String[] args){
        FileReader fr = null;
        FileWriter fw = null;
        try {
            fr = new FileReader("D:\\JAVA\\source\\reader.txt");
            fw = new FileWriter("D:\\JAVA\\target\\test.txt",true);
            int len = 0;
            char[] buff = new char[1024];
            while ((len = fr.read(buff)) != -1){
                fw.write(buff,0,len);
                fw.flush();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if(fr != null){
                    fr.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if(fw != null){
                    fw.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
